package com.lw.question06;

import java.text.DecimalFormat;
import java.util.Arrays;

/**
 * @author LW
 * @2020/9/16 14:14
 */
public class 平均数1 {
    public static void main(String[] args) {
        double x=0;
        double[] num = {9.8,12,45,67,23,1.98,2.55,45};
        Arrays.sort(num);//对数组进行升序排列
        System.out.println("最大值："+num[num.length-1]);
        System.out.println("最小值："+num[0]);
        for (int i = 0; i < num.length; i++) {//遍历数组相加的和
            x += num[i];
        }
        DecimalFormat df = new DecimalFormat("#.00");//保留两位小数
        System.out.println("平均数："+df.format(x/num.length));

    }
}
